package com.kaka.mapper;

import com.kaka.pojo.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface RoleMapper {

    Role selectByUid(int uid);

    List<Role> selectAll();

    Role selectById(int id);

    @Update("update role set roleName=#{roleName},roleDesc=#{roleDesc} where id=#{id}")
    int updatePermission(Role role);

    //查询角色权限管理表中当前角色拥有的权限id集合
    @Select("select permissionId from role_permission where roleId=#{rid}")
    List<Integer> selectAllPermissionId(int rid);

    //删除关联表中当前账号信息
    @Delete("delete from role_permission where roleId=#{rid}")
    int deletePermissionByRId(int rid);

    //添加关联数据
    int addPermissionByList(@Param("rid") Integer rid, @Param("ids") List<Integer> ids);

    @Insert("insert into role(roleName,roleDesc) values(#{roleName},#{roleDesc})")
    int insetRole(Role role);

    @Delete("delete from role where id=#{rid}")
    int deleteById(int rid);

    int deleteByIds(@Param("ids") List<Integer> ids);
}
